package values.skill
{
import core.Configuration;
import core.Language;

import flash.utils.Dictionary;

import isoengine.values.MapSkillRangeList;
import isoengine.values.MapSkillRangeValue;

/**
 * SkillTemplateValue
 * @author jliang
 *
 */
public class SkillTemplateValue implements ISkillProperty
{
	[Data(type="field", mapping="@key")]
	public var key:String;
    
    [Data(type="field", mapping="@avatar_type")]
    public var avatarType:String;
	
	[Data(type="field", mapping="@dynamicRef")]
	public var dynamicRef:String;
	
	[Data(type="field", mapping="@name")]
	public var baseNameKey:String;
	
	public function get name():String
	{
		return Language.getText(baseNameKey);
	}
	
	[Data(type="field" , mapping="@use_count")]
	public var baseUseCount:String;
	
	[Data(type="field" , mapping="@cooling_round")]
	public var baseCoolingRound:String;
	
	[Data(type="field", mapping="@desc")]
	public var baseDescKey:String;
	
	public function get desc():String
	{
		return Language.getText(baseDescKey);
	}
	
	[Data(type="field", mapping="@icon")]
	public var baseIconPath:String;
	
	public function get icon():String
	{
		return Configuration.assetsPath + baseIconPath;
	}
	
	[Data(type="field" , mapping="@ai")]
	public var ai:int = 0;
	
	[Data(type="field" , mapping="@range_target")]
	public var rangeTarget:int = -1;
	
	[Data(type="field", mapping="@demo")]
	public var baseDemoPath:String;
	
	public function get demo():String
	{
		return Configuration.assetsPath + baseDemoPath;
	}
	
	[Data(type="field" , mapping="@demo_class")]
	public var demoClassRef:String;
	
	[Data(type="field" , mapping="@owner_demo")]
	public var baseOwnerDemoPath:String;
	
	public function get ownerDemoPath():String
	{
		return Configuration.assetsPath + baseOwnerDemoPath;
	}
	
	[Data(type="field" , mapping="@owner_demo_class")]
	public var ownerDemoClassRef:String;
	
	[Data(type="field" , mapping="@target")]
	public var target:int;
	
	[Data(type="field" , mapping="@distance")]
	public var distance:String;
	
	[Data(type="field" , mapping="@use_mp")]
	public var use_mp:String;
	
	[Data(type="field" , mapping="@range")]
	public var range:String;
	
	[Data(type="field" , mapping="buffs")]
	public var buffs:*;
	
	private var _baseDamageValue:BaseDamageEffectTemplateValue;
	
	public function get baseDamageValue():BaseDamageEffectTemplateValue
	{
		return _baseDamageValue;
	}
	
	[Data(type="mapping" , mapping="effects.base_damage_effect",
				ref="values.skill.BaseDamageEffectTemplateValue",
					way="own")]
	public function set baseDamageValue(value:BaseDamageEffectTemplateValue):void
	{
		if(value.classRef != "")
		{
			_baseDamageValue = value;
			_baseDamageValue.owner = this;
		}
	}
	
	private var _additional:AdditionalEffectTemplateValue;

	public function get additional():AdditionalEffectTemplateValue
	{
		return _additional;
	}
	
	[Data(type="mapping" , mapping="effects.additional_effect",
				ref="values.skill.AdditionalEffectTemplateValue",
					way="own")]
	public function set additional(value:AdditionalEffectTemplateValue):void
	{
		if(value.classRef != "")
		{
			_additional = value;
			_additional.owner = this;
		}
	}
	
	private var _buffDebuff:BuffDebuffEffectTemplateValue;

	public function get buffDebuff():BuffDebuffEffectTemplateValue
	{
		return _buffDebuff;
	}
	
	[Data(type="mapping" , mapping="effects.buff_debuff_effect",
				ref="values.skill.BuffDebuffEffectTemplateValue",
					way="own")]
	public function set buffDebuff(value:BuffDebuffEffectTemplateValue):void
	{
		if(value.classRef != "")
		{
			_buffDebuff = value;
			_buffDebuff.owner = this;
		}
	}
	
	private var _immediate:ImmediateEffectTemplateValue;

	public function get immediate():ImmediateEffectTemplateValue
	{
		return _immediate;
	}
	
	[Data(type="mapping" , mapping="effects.immediate_effect",
				ref="values.skill.ImmediateEffectTemplateValue",
					way="own")]
	public function set immediate(value:ImmediateEffectTemplateValue):void
	{
		if(value.classRef != "")
		{
			_immediate = value;
			_immediate.owner = this;
		}
	}
	
	private var _logic:LogicEffectTemplateValue;

	public function get logic():LogicEffectTemplateValue
	{
		return _logic;
	}
	
	[Data(type="mapping" , mapping="effects.logic_effect",
				ref="values.skill.LogicEffectTemplateValue",
					way="own")]
	public function set logic(value:LogicEffectTemplateValue):void
	{
		if(value.classRef != "")
		{
			_logic = value;
			_logic.owner = this;
		}
	}
	
	[Data(type="mapping" , mapping="levels.level",
			ref="values.skill.SkillLevelValue",
			way="one_to_more")]
	public var levelList:Array;
	
	public function getLevelValue(value:int):SkillLevelValue
	{
		return levelList[value - 1];
	}
}
}



